import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
import Layout from '@/layout'
export const constantRoutes = [
  
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/index',
    children: [
      {
        path: '/index',
        name: 'Index',
        component: () => import('@/views/index/index'),
        meta: { keepAlive: true, isBack: false }
      },
      {
        path: '/submission',
        name: 'submission',
        component: () => import('@/views/index/submission')
        // meta: { keepAlive: true, isBack: false }
      },
      {
        path: '/list',
        name: 'list',
        component: () => import('@/views/index/list')
      },
      {
        path: '/submit',
        name: 'submit',
        component: () => import('@/views/index/submit')
      },
      {
        path: '/detail',
        name: 'detail',
        component: () => import('@/views/index/detail')
      },
      {
        path: '/decorate',
        name: 'decorate',
        component: () => import('@/views/index/decorate')
      },
      {
        path: '/decoratedetail',
        name: 'decoratedetail',
        component: () => import('@/views/index/decoratedetail')
      },
      
    ]
  },
  { path: '*', redirect: '/404', hidden: true }
]
const createRouter = () =>
  new Router({
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
  })
// const createRouter = () => new Router({
//   base: process.env.BASE_URL,
//   scrollBehavior: () => ({ y: 0 }),
//   routes: constantRoutes
// })
const router = createRouter()
export function resetRouter () {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}
export default router
